﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Slf;

namespace SLF.Test
{
  [TestClass]
  public class DecoratorLoggerTest
  {
    [TestMethod]
    public void RobustnessTest()
    {
      ILogger decoratorLogger = new DecoratorLogger(new DebugLogger(), item =>
          {
            //filter lower level messages
            if (item.LogLevel < LogLevel.Error) return false;

            //transform the logged message
            item.Title = "ERROR - PASSED THE FILTER";
            return true;
          });

      List<string> failures = ExploratoryTester.TestILogger(decoratorLogger);

      Assert.AreEqual(0, failures.Count,
        failures.Count != 0 ? failures.Aggregate((s1, s2) => s1 + System.Environment.NewLine + s2) : "");

    }
  }
}
